package com.example.myapplication.Fragment;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.myapplication.Activity.Mine;
import com.example.myapplication.R;
import com.example.myapplication.Activity.dengLu;

public class MineFragment extends Fragment {
    TextView textView,biaoti;
    SharedPreferences sp;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.activity_mine_fragment,null);
        textView=view.findViewById(R.id.denglu);
        biaoti=view.findViewById(R.id.tv_title);
        biaoti.setText("我的");
        sp=getActivity().getSharedPreferences("zhanghaomima", Context.MODE_PRIVATE);
        String name = sp.getString("zhanghao","");
        int flag = sp.getInt("flag",0);
        if (flag == 0) {
            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent();
                    intent.setClass(getActivity(), dengLu.class);
                    startActivity(intent);
                }
            });
        } else {
            textView.setText(name);
            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent();
                    intent.setClass(getActivity(), Mine.class);
                    startActivity(intent);
                }
            });
        }


        return view;
    }
}